var express = require('express');
var func = require('../control/func');
var router = express.Router();
var multer  = require('multer')
const uuidv1 = require('uuid/v1');
var storage = multer.diskStorage({
  destination: function (req, file, cb) {
    cb(null, 'public/upload')
  },
  filename: function (req, file, cb) {
    cb(null, uuidv1()+file.originalname.slice(-4))
  }
})
var upload = multer({  storage })

/* GET home page. */
router.post('/register',func.register)
  .post('/login',func.login )
  .post('/recentChat',func.recentChat  )
  .post('/getUserChatRecord',func.getUserChatRecord)
  .post('/getUserName',func.getUserName )
  .post('/changeName',func.changeName )
  .post('/getUserName/list', func.getUserName_list)
  .post('/getUserName/state', func.getUserName_state)
  .post('/getNewFriends',func.getNewFriends )
  .post('/addFriends/list',func.addFriends_list )
  .post('/addFriend/request',func.addFriend_request )
  .post('/addFriend/agree', func.addFriend_agree)
  .post('/getUserFriends', func.getUserFriends)
  .post('/getAddFriend', func.getAddFriend)
  .post('/uploadFile',upload.single('file'), func.uploadFile)
module.exports = router;

